﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NUnit.Framework;
using DbSharp.Framework.CaseFile;
using System.Xml.Linq;
using DbSharp.Framework.CaseFile.Parser;
using DbSharp.Framework.Common;


namespace UnitTestProject.CaseFile
{

    [TestFixture]
    public class ResultsetOutputSettingTest
    {
        [Test]
        public void ParseDefaultRSOutSetting()
        {
            CaseFileNavigator fileNavigator = new CaseFileNavigator(@"CaseFileSample\TestCase_V2_GlobalSet_Normal.xml");
            XElement globalSettingElmt = fileNavigator.SelectGlobalSetting();

            DefaultRsOutputSetting setting = null;
            var parser = new DefaultRsOutputSettingParser(globalSettingElmt);

            setting = parser.Setting;
            Assert.AreEqual(250, setting.ExportRecordCount);
        }


        [Test]
        public void ParseDefaultRSOutSetting_No_Element()
        {
            CaseFileNavigator fileNavigator = new CaseFileNavigator(@"CaseFileSample\TestCase_V2_GlobalSet_No_DefaultRSOutSetting.xml");
            XElement globalSettingElmt = fileNavigator.SelectGlobalSetting();

            DefaultRsOutputSetting setting = null;
            var parser = new DefaultRsOutputSettingParser(globalSettingElmt);

            setting = parser.Setting;
            if (setting.ExportRecordCount <= 100)
                throw new DbSharpException("default exportRecordCount should be greater than 100.");
        }
    }


}
